<?php
/**
 * Created by PhpStorm.
 * User: ybjaa
 * Date: 2017/4/21
 * Time: 15:40
 */

namespace App\Business\DataLog;


use App\Models\log_request;

class DataRequest extends LogBase
{
    protected function defaultInitialize()
    {
        $this->log=new log_request();

        $method=strtoupper(request()->method());

        $this->log->method=$method;
        $this->log->contentType=request()->getContentType();

        switch ($method)
        {
            case "GET":
            case "DELETE":
                $this->log->content=json_encode($_GET);
                break;

            case "POST":
            case "PUT":

            switch(strtoupper(request()->getContentType()))
            {
                case "FORM":
                    $this->log->content=json_encode($_POST);
                    break;

                case "JSON":
                    $this->log->content=request()->getContent();
                    break;

                default:break;
            }

            break;


            default:break;
        }


    }

}